﻿<UserControl x:Class="XERP.Client.WPF.MenuItemMaintenance.Views.MainMaintenanceSearchView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
            d:DesignHeight="600" d:DesignWidth="650"
             IsEnabled="{Binding Path=FormIsEnabled}">
    <Grid Style="{StaticResource BaseGrid}">
        <Grid.RowDefinitions>
            <RowDefinition Height="25" />
            <RowDefinition Height="119*" />
            <RowDefinition Height="196*" />
            <RowDefinition Height="32*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions >
            <ColumnDefinition Width="116*" />
            <ColumnDefinition Width="226*" />
            <ColumnDefinition Width="158*" />
        </Grid.ColumnDefinitions>
        <GridSplitter Style="{StaticResource BaseHorizontalGridSplitter}" Grid.Row="0" Grid.ColumnSpan="3" 
                      Grid.RowSpan="2" HorizontalAlignment="Stretch" />
        <TextBlock Style="{StaticResource BaseHeader}" Grid.ColumnSpan="2" HorizontalAlignment="Center"
                   Margin="5">Menu Item Search</TextBlock>
        <StackPanel Style="{StaticResource BaseStackPanel}" Grid.Row="1"
                    HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Orientation="Vertical">
            <TextBlock Style="{StaticResource BaseTextBlock}" 
                       HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8">Name:</TextBlock>
            <TextBlock Style="{StaticResource BaseTextBlock}"
                       HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8">Description:</TextBlock>
            <TextBlock Style="{StaticResource BaseTextBlock}"
                       HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8">Type:</TextBlock>
            <TextBlock Style="{StaticResource BaseTextBlock}"
                       HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8">Code:</TextBlock>
        </StackPanel>
        <StackPanel Style="{StaticResource BaseStackPanel}" Grid.Row="1" Grid.Column="1" 
                    HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Orientation="Vertical">
            <TextBox Style="{StaticResource BaseTextBox}" Margin="5" Width="250"
                                 Text="{Binding Path=SearchObject.Name}"/>
            <TextBox Style="{StaticResource BaseTextBox}" Margin="5" Width="250"
                                 Text="{Binding Path=SearchObject.Description}"/>
            <ComboBox Style="{StaticResource BaseComboBox}" Width="250" Margin="5"
                              ItemsSource="{Binding Path=MenuItemTypeList, Mode=TwoWay}"
                              DisplayMemberPath="Type"
                              SelectedValue="{Binding Path=SearchObject.MenuItemTypeID, Mode=TwoWay}"
                              SelectedValuePath="MenuItemTypeID"/>
            <ComboBox Style="{StaticResource BaseComboBox}" Width="250" Margin="5"
                              ItemsSource="{Binding Path=MenuItemCodeList, Mode=TwoWay}"
                              DisplayMemberPath="Code"
                              SelectedValue="{Binding Path=SearchObject.MenuItemCodeID, Mode=TwoWay}"
                              SelectedValuePath="MenuItemCodeID"/>
        </StackPanel>
        <StackPanel Style="{StaticResource BaseStackPanel}" Grid.Column="2" Grid.Row="1" 
                    HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Orientation="Vertical">
            <Button Style="{StaticResource BaseButton}" Content="Search" Height="23"  Width="75"  Margin="5">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:CallMethodAction
                        TargetObject="{Binding}"
                        MethodName="SearchCommand"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
            <Button Style="{StaticResource BaseButton}" Content="Cancel" Height="23"  Width="75"  Margin="5" 
                    Click="Cancel_Click"/>
        </StackPanel>
        <DataGrid Style="{StaticResource BaseDataGrid}" Grid.Row="2" Grid.ColumnSpan="3"
                  ItemsSource="{Binding ResultList}" AutoGenerateColumns="False" Name="dgResult" 
                  SelectionMode="Extended" CanUserAddRows="false" CanUserDeleteRows="False" 
                  Margin="0,6,0,0" SelectionChanged="DataGrid_SelectionChanged">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding MenuItemID}"
                                                Header="ID" Width="*" IsReadOnly="True"/>
                <DataGridTextColumn Binding="{Binding Name}"
                                                Header="Name" Width="*" IsReadOnly="True"/>
                <DataGridTextColumn Binding="{Binding Description}"
                                                Header="Description" Width="Auto" IsReadOnly="True"/>
                <DataGridTextColumn Binding="{Binding MenuItemTypeID}"
                                                Header="Type" Width="*" IsReadOnly="True"/>
            </DataGrid.Columns>
        </DataGrid>
        <Button Style="{StaticResource BaseButton}" Grid.Column="1" Grid.Row="3" 
                Height="23" Content="OK" Margin="5" Width="75">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <ei:CallMethodAction
                    TargetObject="{Binding}"
                    MethodName="CommitSearchCommand"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
    </Grid>
</UserControl>
